import java.util.*;
public class Test {
    public static void main(String[] args) {

        long count = 0 ;
        for (long i = 2022; i <= 2022222022 ; i++) {
            //判断回文
            if(is(i) && is1(i)) {
                count++;
            }

        }
        System.out.println(count);
    }
    public static boolean is(long x) {
        String s = x+"";
        int l = 0,r = s.length()-1;
        while(l < r) {
            if(s.charAt(r) != s.charAt(l)) {
                return false;
            }
            l++;
            r--;
        }
        return  true;
    }
    public static boolean is1(long x ) {
        String s = x+"";
        int k = (s.length()+1)/2;
        for (int i = 1; i < k; i++) {
            if(s.charAt(i) < s.charAt(i-1) ) {
                return false;
            }

        }
        return true;
    }

}


